import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;


public class Helper {
	public static void writeToFile(double[][] toWrite, String filename)
	{
		Path path = Paths.get(filename);
	    try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)){
	      for(int i = 0; i< toWrite.length;i++){
	    	  String line = "";
	    	  for (int j = 0; j < toWrite[i].length; j++)
	    	  {
	    		  double erg = toWrite[i][j];
		    	  	 erg = erg*1000;
		    	  	 erg = Math.floor(erg);
		    	  	 erg = erg/1000;
		    		  line+=erg+"\t";
	    		  
	    	  }
	    	  //line+="\n";
	    	  line = line.substring(0, line.length()-2);
	        writer.write(line);
	        writer.newLine();
	      }
	      writer.close();
	    } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void writeToFile(double[] toWrite, String filename)
	{
		Path path = Paths.get(filename);
	    try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)){
	    	String line = "";
	      for(int i = 0; i< toWrite.length;i++){
	    	  
	    	  
	    	  	double erg = toWrite[i];
	    	  	 erg = erg*1000;
	    	  	 erg = Math.floor(erg);
	    	  	 erg = erg/1000;
	    		  line+=erg+"\t";
	    	  
	        
	      }
	      line = line.substring(0, line.length()-2);
	      writer.write(line);
	        writer.newLine();
	        writer.close();
	    } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void writeToFile(int[] toWrite, String filename)
	{
		Path path = Paths.get(filename);
	    try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)){
	    	String line = "";
	      for(int i = 0; i< toWrite.length;i++){
	    	  
	    	  	 
	    		  line+=toWrite[i]+"\t";
	    	  
	        
	      }
	      line = line.substring(0, line.length()-2);
	      writer.write(line);
	        writer.newLine();
	        writer.close();
	    } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
